package be.jhd.utils;

import java.io.File;

import be.jhd.repository.Artifact;

public class ArtifactNameResolver {

	public static String resolve(Artifact artifact){
		StringBuilder builder = new StringBuilder();
		builder.append(artifact.getArtifact()).append("-").append(artifact.getVersion());
		
		if(artifact.isSnapshot()){
			builder.append(Artifact.SNAPSHOT);
		}
		
		if(artifact.isClassified()){
			builder.append("-").append(artifact.getClassifier());
		}
		
		builder.append(".").append(artifact.getPackaging());
		
		return builder.toString();
	}
	
	public static String resolveAbsolutePath(Artifact artifact){
		final String artifactName = resolve(artifact);
		File file = new File(artifactName);
		return file.getAbsolutePath();
	}
}
